﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VirtualTFS.DAL;
using VirtualTFS.DAL.Models;
using VirtualTFS.DAL.Repositories;

namespace VirtualTFS.BL
{
    public class WikiImpl
    {
        public void CreateWiki(WikiModel wikiModel)
        {
            var wikiRepository = new WikiRepository();
            wikiRepository.AddWiki(wikiModel.MapWiki());
            wikiRepository.Commit();
        }

        public void EditWiki(WikiModel wikiModel)
        {
            var wikiRepository = new WikiRepository();
            wikiRepository.UpdateWiki(wikiModel.MapWiki());
            wikiRepository.Commit();
        }

        public void DeleteWiki(WikiModel wikiModel)
        {
            var wikiRepository = new WikiRepository();
            wikiRepository.DeleteWiki(wikiModel.MapWiki());
            wikiRepository.Commit();
        }

        public IList<WikiModel> GetListWikiModel()
        {
            var wiki = new WikiRepository();
            IList<WikiModel> listWiki = wiki.GetAllWiki().Select(x=>new WikiModel(x)).ToList();
            return listWiki;
        }

        public Wiki GetWikiInfo(System.Guid id)
        {
            var wiki = new WikiRepository();
            var wikiInfo = wiki.GetSingleWiki(x => x.Id == id);
            return wikiInfo;
        }
    }
}
